package muse.widgets;

import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;

public class CyclerWidget extends Widget {

    JPanel widgetBody;
    JPanel leftArrow;
    JPanel rightArrow;
    
    @Override
    public Dimension getPreferredSize() {
            return new Dimension();
    }

    @Override
    public String getIcon() {
            return "";
    }

    public CyclerWidget()
    {
        this.setLayout(new BorderLayout());
        JPanel all = new JPanel();
        
        
        all.setLayout(new GridBagLayout());
        
        GridBagConstraints c = new GridBagConstraints(); 
        
        leftArrow = new JPanel () {
            public void paintComponent(Graphics g)
            {            
                int x1 = getWidth()-1;
                int x2 = 0;
                int x3 = getWidth()-1;
                int y1 = 0;
                int y2 = getHeight()/2;
                int y3 = getHeight();
                int x[] = {x1, x2, x3};
                int y[] = {y1, y2, y3};
                
                g.setColor(Color.green);
                g.fillPolygon(new Polygon(x, y, 3));
                g.setColor(Color.black);
                g.drawPolygon(new Polygon(x, y, 3));
            }
        };
        leftArrow.setBackground(Color.ORANGE);
        c.fill = GridBagConstraints.BOTH;
        c.gridx = 0;
        c.gridy = 0;
        c.ipadx = 0;
        c.ipady = 0;
        c.weightx = 0.2;
        c.weighty = 0.8;
        c.insets = new Insets(0, 0, 0, 0);        
        all.add(leftArrow, c);
        
        widgetBody = new JPanel();
        widgetBody.setBorder(BorderFactory.createLineBorder(Color.black));
        c.fill = GridBagConstraints.BOTH;
        c.gridx = 1;
        c.gridy = 0;
        c.ipadx = 0;
        c.ipady = 0;
        c.weightx = 1;
        c.weighty = 0.8;
        c.insets = new Insets(0, 0, 0, 0);
        all.add(widgetBody, c);
        
        rightArrow = new JPanel () {
            public void paintComponent(Graphics g)
            {
                int x1 = 0;
                int x2 = getWidth();
                int x3 = 0;
                int y1 = 0;
                int y2 = getHeight()/2;
                int y3 = getHeight();
                int x[] = {x1, x2, x3};
                int y[] = {y1, y2, y3};
                
                g.setColor(Color.green);
                g.fillPolygon(new Polygon(x, y, 3));
                g.setColor(Color.black);
                g.drawPolygon(new Polygon(x, y, 3));
            }
        };
        
        rightArrow.setBackground(Color.ORANGE);
        c.fill = GridBagConstraints.BOTH;
        c.gridx = 2;
        c.gridy = 0;
        c.ipadx = 0;
        c.ipady = 0;
        c.weightx = 0.2;
        c.weighty = 0.8;
        c.insets = new Insets(0, 0, 0, 0);
        all.add(rightArrow, c);
        
        this.add(all);
        
    }
    
}
